/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.expert.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.chlitina.store.common.service.BaseService;
import com.chlitina.store.modules.expert.dao.CustomerSolutionAndProductDao;
import com.chlitina.store.modules.expert.entity.CustomerSolutionAndProduct;

/**
 * 客户采纳产品Service
 * @author lvbo
 * @version 2013-06-20
 */
@Component
@Transactional(readOnly = true)
public class CustomerSolutionAndProductService extends BaseService {

	@SuppressWarnings("unused")
	private static Logger logger = LoggerFactory.getLogger(CustomerSolutionAndProductService.class);
	
	@Autowired
	private CustomerSolutionAndProductDao customerSolutionAndProductDao;
	
	public CustomerSolutionAndProduct getOneByPK(Long cid,Long pid) {
		return customerSolutionAndProductDao.findByPKId(cid, pid);
	}
	
	@Transactional(readOnly = false)
	public void save(CustomerSolutionAndProduct c) {
		customerSolutionAndProductDao.save(c);
	}
	
	public List<CustomerSolutionAndProduct> find(Long customerSolutionId) {
		DetachedCriteria dc = customerSolutionAndProductDao.createDetachedCriteria();
		if (customerSolutionId != null) {
			dc.add(Restrictions.eq("customerSolution.id", customerSolutionId));
			return customerSolutionAndProductDao.find(dc);
		}
		return null;
	}
}
